]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
slider: Consider text direction when handling arrow keys
authorSundeep Mediratta <smedius@gmail.com>
Wed, 9 Oct 2024 17:17:30 +0000 (13:17 -0400)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 17 Oct 2024 16:52:28 +0000 (18:52 +0200)
Currently the right arrow key always increases the slider value,
even in RTL locales where the slider itself increases leftwards.

Fix that, so that the arrow keys always correspond to the
direction of the slider.

Closes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7963

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3500>
(cherry picked from commit 5309f747fad23ebc707870868016f0414776e59c)

js/ui/slider.js

index fc4a2579b2b0f869a2814c8b66bbfcc6f2d5e83c..06a6843bab93091d40b61d5ec458fd44a8d00885 100644 (file)
@@ -193,7 +193,9 @@ export const Slider = GObject.registerClass({
     vfunc_key_press_event(event) {
         let key = event.get_key_symbol();
         if (key === Clutter.KEY_Right || key === Clutter.KEY_Left) {
-            let delta = key === Clutter.KEY_Right ? 0.1 : -0.1;
+            const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
+            const increaseKey = rtl ? Clutter.KEY_Left : Clutter.KEY_Right;
+            const delta = key === increaseKey ? 0.1 : -0.1;
             this.value = Math.max(0, Math.min(this._value + delta, this._maxValue));
             return Clutter.EVENT_STOP;
         }